﻿using BP.DA;
using BP.Difference;
using BP.En;
using BP.Sys;
using BP.Web;
using BP.WF;
using BP.WF.HttpHandler;
using BP.WF.Template;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using System;
using System.Collections;
using System.Data;
using System.Net.Http;
using System.Text;
using BP.WF.DTS;
using System.Security.Cryptography;
using BP.Tools;
using DocumentFormat.OpenXml.ExtendedProperties;
using NPOI.SS.Formula.Functions;
using BP.Port;
using System.Collections.Generic;
using BP.WF.CCFast.Third.GoView;
using NPOI.Util;
using NPOI.SS.Util;
using NPOI.HPSF;
using NetTaste;
using Microsoft.AspNetCore.Http;
using System.IO;
using System.Text.Json.Nodes;
using DocumentFormat.OpenXml.Drawing.Charts;
using static CCFlow.NetCore.DataUser.API.Controllers.APIController;
using DataTable = System.Data.DataTable;

namespace CCFlow.NetCore.DataUser.API.Controllers
{
    [Route("WF/[controller]/[Action]")]
    [ApiController]
    public class BigAPIController : ControllerBase
    {
        /// <summary>
        /// 返回信息格式
        /// </summary>
        /// <param name="code">200=成功，500=异常</param>
        /// <param name="msg"></param>
        /// <param name="data"></param>
        /// <returns></returns>

        protected static object Return_Info(int code, string msg, object data)
        {
            Hashtable ht = new Hashtable();
            ht.Add("code", code); // 200=成功，500=失败.
            ht.Add("message", msg);  //执行信息.
            ht.Add("data", data);  //一般是json.
            return ht;
            //string json = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":\"" + data + "\"}";
            //return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.GetEncoding("UTF-8"), "application/json") };
        }

        /**
         * 蓝色大屏-登陆
         * @param user 用户vo
         * @param token
         * @return
         * @throws Exception
         */
        [HttpGet, HttpPost]
        public AjaxResult Port_LoginByPassword(SysUser user, string token)
        {
            BP.Tools.AjaxResult json = new BP.Tools.AjaxResult();
            try {

                if (token != null) {
                    Dev2Interface.Port_LoginByToken(token);
                }

                BP.Port.Emp emp = new BP.Port.Emp();
                emp.No = user.username;
                if (emp.RetrieveFromDBSources() == 0)
                {
                    json.Add("code", 500);
                    json.Add("msg", "用户名或者密码错误");
                    return json;
                }

                if (emp.CheckPass(user.password) == false)
                {
                    json.Add("code", 500);
                    json.Add("msg", "用户名或者密码错误");
                    return json;
                }

                //先登录再获取Token.
                Dev2Interface.Port_Login(emp.UserID);
                token = Dev2Interface.Port_GenerToken(emp.No, "PC");

                user.username = WebUser.Name;
                user.nickname = WebUser.Name;
                user.password = null;
                user.id = WebUser.No;

                Dictionary<string, object> map = new Dictionary<string, object>();
                map.Add("userinfo", user);
                BP.WF.CCFast.Third.GoView.Token token2 = new BP.WF.CCFast.Third.GoView.Token();
                token2.setTokenName("satoken");
                token2.setTokenValue(token);
                map.Add("token", token2);

                json.Add("code", 200);
                json.Add("data", map);
                json.Add("msg", "登录成功！");
                return json;
            } catch (Exception e) {
                json.Add("code", 500);
                json.Add("msg", e.Message);
                return json;
            }
        }

       /**
         * 蓝色大屏-退出登录
        */
        [HttpGet, HttpPost]
        public  Object Portal_LoginOut()
        {
        try{
            Dev2Interface.Port_SigOut();
            return Return_Info(200, "退出成功", "退出成功");
            }catch(Exception e){
            return Return_Info(500,"退出成功失败", e.Message);
            }
        }
         /**
         * 蓝色大屏-获取oss地址
          */
        [HttpGet, HttpPost]
        public Object getOssInfo()
         {
            string fullUrl = HttpContextHelper.fullUrl;
            string prefix = fullUrl.Substring(0, fullUrl.IndexOf("/", 8));
              
            prefix = prefix + "/DataUser/";
            return Return_Info(200, "获取成功", prefix);
         }

        [HttpGet, HttpPost]
        public Object Search_EmpByToken(string Token)
        {
            BP.Port.Token tk = new BP.Port.Token();
            tk.setMyPK(Token);
            if (tk.RetrieveFromDBSources() == 0)
            {
                throw new RuntimeException("err@ token 过期或失效.");
            }
            DataTable dt = tk.ToDataTableField();
            return Return_Info(200, "根据Token获取人员信息成功", Json.ToJson(dt));
        }

        /**
         *蓝色大屏- 获取项目列表
         */
        [HttpGet, HttpPost]
        public object projectList(string token)
        {
           
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);
            //string userName = WebUser.getName();
            string userName = WebUser.UserID;

            string execSql = "select mypk as id , ProjectName as projectName,CreateTime as createTime,"
                    + "CreateUserId as createUserId,State as state,isDelete,indexImage,Remarks from goview_projects t "
                    + " where 1=1 and createUserId = '" + userName + "'  and isTemplate=-1 ";
            DataTable dt = DBAccess.RunSQLReturnTable(execSql);
            int count = dt.Rows.Count;

            Hashtable ht = new Hashtable();
            ht.Add("code", 200);
            ht.Add("message", "获取成功");
            ht.Add("data", Json.ToJson(dt));
            ht.Add("count", count);
            return ht;
        }

        /**
         * 蓝色大屏-获取项目模板列表
         */
        [HttpGet, HttpPost]
        public Object projectTemplateListApi(string token)
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);
            string userName = WebUser.UserID;

            string execSql = "select mypk as id , ProjectName as projectName,CreateTime as createTime,"
                    + "CreateUserId as createUserId,State as state,isDelete,indexImage,Remarks from goview_projects t "
                    + " where 1=1 and createUserId = '" + userName + "' and isTemplate=1 ";
            DataTable dt = DBAccess.RunSQLReturnTable(execSql);
            int count = dt.Rows.Count;


            Hashtable ht = new Hashtable();
            ht.Add("code", 200);
            ht.Add("message", "获取成功");
            ht.Add("data", Json.ToJson(dt));
            ht.Add("count", count);
            return ht;
        }

        /**
         * 蓝色大屏-新增保存项目信息
         * @param
         * @return
         */
        [HttpGet, HttpPost]
        public object create([FromBody] GoviewProjectVo goviewProjectVo )
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);

            GoviewProject goviewProject = new GoviewProject();
            goviewProject.ProjectName = goviewProjectVo.projectName;
            goviewProject.setMyPK(goviewProjectVo.projectName);

            string datestring = DataType.CurrentDateTimess;
            goviewProject.CreateTime = datestring;
            goviewProject.CreateUserId = goviewProjectVo.createUserId;
            goviewProject.State=-1;
            goviewProject.isTemplate = -1;

            try
            {
                int b = goviewProject.Insert();
                if (b > 0)
                {
                    goviewProjectVo.state=-1;
                    goviewProjectVo.createTime=datestring;
                    return Return_Info(200, "创建成功", goviewProjectVo);
                }
                else
                {
                    return Return_Info(500, "创建失败", "");
                }
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
                return Return_Info(500, "创建失败", "");
            }
        }

         /**
         * 蓝色大屏-通过模板创建项目
         * @param
         * @return
         */
         [HttpGet, HttpPost]
        public Object createByTemplate([FromBody] GoviewProjectVo goviewProjectVo )
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);

            GoviewProject goviewProject = new GoviewProject();
            goviewProject.ProjectName = goviewProjectVo.projectName;
            goviewProject.setMyPK(goviewProjectVo.projectName);

            string datestring = DataType.CurrentDateTimess;
            goviewProject.CreateTime = datestring;
            goviewProject.CreateUserId = goviewProjectVo.createUserId;
            goviewProject.State = -1;
            goviewProject.isTemplate = -1;

            try
            {
                int b = goviewProject.Insert();
                if (b > 0)
                {
                    goviewProjectVo.state=-1;
                    goviewProjectVo.createTime=datestring;

                    //GoviewProjectData goviewProjectData= new GoviewProjectData();
                    string execSql = "select mypk as id , projectid ,Content from goview_projectdatas where projectid = '" + goviewProjectVo.templateID + "'";
                    DataTable dt = DBAccess.RunSQLReturnTable(execSql);
                    int count = dt.Rows.Count;
                    GoviewProjectData goviewProjectData = new GoviewProjectData();
                    if (count > 0)
                    {
                        //string content = (string) dt.getValue(0, "Content");
                        //goviewProjectData.
                        string ids = dt.Rows[0]["id"].ToString();
                        string content = dt.Rows[0]["Content"].ToString();

                        goviewProjectData.CreateTime=datestring;
                        goviewProjectData.ProjectId=goviewProjectVo.projectName;
                        goviewProjectData.Content=content;

                        goviewProjectData.SaveBigTxtToDB("Content", content);
                        goviewProjectData.Save();
                        //goviewProjectData.Update();
                    }
                    else
                    {
                        goviewProjectData.ProjectId=goviewProjectVo.projectName;
                        //goviewProjectData.setContent(content);
                        goviewProjectData.CreateTime=datestring;
                        goviewProjectData.Save();
                    }


                    return Return_Info(200, "创建成功", goviewProjectVo);
                }
                else
                {
                    return Return_Info(500, "创建失败", "");
                }
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
                return Return_Info(500, "创建失败", "");
            }
        }

        /**
          * 蓝色大屏-项目表删除
          * @param ids
          * @return
          */
        [HttpGet, HttpPost, HttpDelete]
        public Object delete(string ids)
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);
            try
            {
                GoviewProject goviewProject = new GoviewProject(ids);
                //goviewProject.setMyPK(ids);
                int t = goviewProject.Delete();
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
                return Return_Info(500, "删除失败", "");
            }
            return Return_Info(200, "删除成功", "");
        }
        /**
          * 蓝色大屏-修改项目
          * @param goviewProjectVo
          * @return
          */
        [HttpGet, HttpPost]
        public Object edit([FromBody] GoviewProjectVo goviewProjectVo)
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);
            try
            {
                //goviewProject.Save();
                GoviewProject goviewProject = new GoviewProject(goviewProjectVo.id);
                //goviewProject.setMyPK(goviewProjectVo.getId());

                if (goviewProjectVo.projectName != null)
                {
                    goviewProject.ProjectName=goviewProjectVo.projectName;
                }
                if (goviewProjectVo.indexImage != null)
                {
                    goviewProject.indexImage = goviewProjectVo.indexImage;
                }

                //goviewProject.
                goviewProject.Update();
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
            }
            return Return_Info(200, "获取成功", "");

        }

        /**
         * 蓝色大屏-项目重命名
         * @param goviewProjectVo
         * @return
         */
        [HttpGet, HttpPost]
        public Object rename([FromBody] GoviewProjectVo goviewProjectVo)
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);

            GoviewProject goviewProject = new GoviewProject();
            goviewProject.setMyPK(goviewProjectVo.id);
            goviewProject.ProjectName = goviewProjectVo.projectName;
            try
            {
                //goviewProject.Save();
                goviewProject.Update();
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
                return Return_Info(500, "重命名失败", "");
            }
            return Return_Info(200, "重命名成功", "");
        }


        /**
         * 蓝色大屏-发布项目
         * @param goviewProjectVo
         * @return
         */
        [HttpGet, HttpPost, HttpPut]
        public Object publish([FromBody] GoviewProjectVo goviewProjectVo)
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);

            if (goviewProjectVo.state == -1 || goviewProjectVo.state == 1)
            {
                try
                {
                    GoviewProject goviewProject = new GoviewProject(goviewProjectVo.id);
                    goviewProject.setMyPK(goviewProjectVo.id);
                    goviewProject.State=goviewProjectVo.state;
                    goviewProject.Update();
                }
                catch (Exception e)
                {
                    BP.DA.Log.DebugWriteError(e);
                    return Return_Info(500, "发布失败", "");
                }
            }
            return Return_Info(200, "发布成功", "");
        }
        /**
         * 蓝色大屏-设置项目为模板
         * @param goviewProjectVo
         * @return
         */
        [HttpGet, HttpPost, HttpPut]
        public Object setTemplate([FromBody] GoviewProjectVo goviewProjectVo)
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);
            if (goviewProjectVo.isTemplate == -1 || goviewProjectVo.isTemplate == 1)
            {
                try
                {
                    GoviewProject goviewProject = new GoviewProject(goviewProjectVo.id);
                    goviewProject.setMyPK(goviewProjectVo.id);
                    goviewProject.isTemplate=goviewProjectVo.isTemplate;
                    goviewProject.Update();
                }
                catch (Exception e)
                {
                    BP.DA.Log.DebugWriteError(e);
                    return Return_Info(500, "设置失败", "");
                }
            }
            return Return_Info(200, "设置模板成功", "");
        }
        /**
          * 蓝色大屏-设置项目为模板
          * @param goviewProjectVo
          * @return
          */
        [HttpGet, HttpPost]
        public Object getData(string projectId)
        {
    
            GoviewProjectVo goviewProjectVo = new GoviewProjectVo();
            try
            {
                GoviewProject goviewProject = new GoviewProject(projectId);
                goviewProjectVo.id=projectId;
                goviewProjectVo.projectName=goviewProject.ProjectName;
                goviewProjectVo.indexImage=goviewProject.indexImage;
                goviewProjectVo.remarks=goviewProject.Remarks;
                goviewProjectVo.state=goviewProject.State;

                Paras pens = new Paras();
                pens.SQL = "select mypk as id , projectid ,Content from goview_projectdatas where projectid = " + SystemConfig.AppCenterDBVarStr + "v";
                pens.Add("v", projectId);
                DataTable dt = DBAccess.RunSQLReturnTable(pens);
                int count = dt.Rows.Count;
                if (count > 0)
                {
                    string content = (string)dt.Rows[0]["Content"].ToString();
                    goviewProjectVo.content=content;
                    return Return_Info(200, "获取成功",goviewProjectVo);
                }
                else
                {
                    return Return_Info(200, "无数据", "null");
                }

            }
            catch (Exception e)
            {
                return Return_Info(500, "无数据", "");
            }
         }
        /**
          * 蓝色大屏-保存设计信息
          * @param goviewProjectVo
          * @return
          */
        [HttpPost]
        public Object saveData([FromBody] GoviewProjectDataVo data )
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);

            BP.Tools .AjaxResult json = new BP.Tools.AjaxResult();
            GoviewProjectData goviewProjectData = new GoviewProjectData();

            try
            {
                GoviewProject goviewProject = new GoviewProject(data.projectId);
                if (goviewProject == null)
                {
                    return Return_Info(500, "没有项目信息", "");
                }
                //GoviewProjectData goviewProjectData= new GoviewProjectData();
                string execSql = "select mypk as id , projectid ,Content from goview_projectdatas where projectid = '" + data.projectId + "'";
                DataTable dt = DBAccess.RunSQLReturnTable(execSql);
                int count = dt.Rows.Count;
                string datestring = DataType.CurrentDateTimess;
                if (count > 0)
                {
                    //string content = (string) dt.getValue(0, "Content");
                    //goviewProjectData.
                    string ids = dt.Rows[0]["id"].ToString();
                    string projectid = dt.Rows[0]["projectid"].ToString();

                    goviewProjectData.CreateTime=datestring;
                    goviewProjectData.setMyPK(ids);
                    goviewProjectData.ProjectId=projectid;
                    goviewProjectData.Content=data.content;

                    goviewProjectData.SaveBigTxtToDB("Content", data.content);
                    goviewProjectData.Save();
                    //goviewProjectData.Update();
                }
                else
                {
                    goviewProjectData.ProjectId=data.projectId;
                    goviewProjectData.CreateTime=datestring;
                    goviewProjectData.Save();
                }

            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
                return Return_Info(500, "保存数据失败", "");
            }

            json.Add("msg", "保存数据成功");
            json.Add("code", 200);
            return Return_Info(200, "保存数据成功", "");
        }
        /**
          * 蓝色大屏-通过Token登陆
          * @param token
          * @return
          */
        [HttpGet, HttpPost]
        public Object loginByToken(string token)  {
            AjaxResult json = new AjaxResult();
		try{
			if(DataType.IsNullOrEmpty(token) == true){
			   	json.Add("code", 500);
		        json.Add("data", "");
		        json.Add("msg","Token为空");
	            return json;
			}else {
	            Dev2Interface.Port_LoginByToken(token);
			}
            SysUser user = new SysUser();

            user.username=WebUser.Name;
            user.nickname=WebUser.Name;
            user.password=null;
            user.id=WebUser.No;

            BP.WF.CCFast.Third.GoView.Token token2 = new BP.WF.CCFast.Third.GoView.Token();
            token2.setTokenName("satoken");
            //token2.setIsLogin(bp.web.WebUser.);
            token2.setTokenValue(WebUser.Token);

            Dictionary<string, object> map = new Dictionary<string, object>();
            map.Add("userinfo", user);
            map.Add("token", token2);

            return Return_Info(200, "登录成功", map);
        }catch(Exception e){
                BP.DA.Log.DebugWriteError(e);
                return Return_Info(500,"登录有错误！","");
        }
     }
        /**
          * 蓝色大屏-上传文件
          * @param token
          * @return
          */
        [HttpGet, HttpPost]
        public Object upload() 
        {
            // 获取请求头中的Satoken
            var Satoken = Request.Headers["Satoken"];
            Dev2Interface.Port_LoginByToken(Satoken);

            if (HttpContextHelper.RequestFilesCount < 0 )
            {
                return Return_Info(500, "上传文件不能为空", "");
            }
            string fileName = "";
             string basePath = SystemConfig.PathOfDataUser;
            //basePath = basePath.Replace("\\\\", "\\");
            basePath = basePath.Replace("\\\\", "/");
            basePath = basePath.Replace("\\", "/");
            /*if (SystemConfig.isjarJarRun == true)
                basePath = SystemConfig.getPhysicalPath() + "DataUser" + File.separator;*/
            //上传附件
            string filepath = "UploadFile/goview";
            IFormFile file = HttpContextHelper.RequestFiles(0);
            if (file == null)
            {
                return Return_Info(500, "获取附件信息有误", "失败");
            }
         
            string fileFullPath = basePath + filepath;
          
            // 获取文件名
            fileName = HttpContextHelper.GetNameByIdx(0);
            if (fileName.IndexOf("/") > -1) {
                fileName = fileName.Substring(fileName.LastIndexOf("/") + 1);
                fileName = fileName.Replace(" ", "");
            }
            string savefileFullPath = fileFullPath + "/" + DBAccess.GenerGUID() + fileName;

            try
            {
                //上传文件.
                if (System.IO.Directory.Exists(fileFullPath) == false)
                    System.IO.Directory.CreateDirectory(fileFullPath);
                HttpContextHelper.UploadFile(HttpContextHelper.RequestFiles(0), savefileFullPath);
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
                return Return_Info(500, e.Message, "失败");
            }

            try
            {
                float size = HttpContextHelper.RequestFileLength(HttpContextHelper.RequestFiles(0)) / 1024;
                string fileName1 = fileName.Substring(0, fileName.LastIndexOf("."));

                SysFileVo sysFileVo = new SysFileVo();
                sysFileVo.setFileName(fileName1);
                sysFileVo.setFileurl(filepath);
                sysFileVo.setFileSize(size.ToString());
                return Return_Info(200, "创建成功", sysFileVo);
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
                return Return_Info(500, "创建失败", "");
            }

	     }
        /**
          * 蓝色大屏-动态数据测试1
          * @param key
          * @param sql
          * @return
        */
        [HttpGet, HttpPost]
        public object test1(string key,string sql)
        {
            try
            {
              /*  System.out.println("test3：" + key);
                System.out.println("sql:" + sql);*/
                string p = "";
                string rstr = "sql默认文本";
                if (key != null && !key.Equals(""))
                {
                   // System.out.println("key:" + key);
                    p = key;
                }

                if (p.Equals("1"))
                {
                    rstr = "sql选项1";
                }
                else if (p.Equals("2"))
                {
                    rstr = "sql选项2";
                }
                return Return_Info(0, "", rstr);
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
            }
            return null;
        }

        /**
        * 蓝色大屏-动态数据测试2
        * @param token
        * @return
         */
        [HttpGet, HttpPost]
        public object test2(string key)
        {
            try
            {
               // System.out.println("test2：" + key);
                string p = "";
                string rstr = "{\"dimensions\":[\"product\",\"data1\"],\"source\":[{\"product\":\"Sat\",\"data1\":110},{\"product\":\"Sun\",\"data1\":130},{\"product\":\"Wed\",\"data1\":150},{\"product\":\"Thu\",\"data1\":80}]}";
                if (key != null && !key.Equals(""))
                {
                    //System.out.println("key:" + key);
                    p = key;
                }
                if (p.Equals("1"))
                {
                    rstr = "{\"dimensions\":[\"product\",\"data1\"],\"source\":[{\"product\":\"Mon\",\"data1\":120},{\"product\":\"Tue\",\"data1\":200},{\"product\":\"Wed\",\"data1\":150}]}";
                }
                else if (p.Equals("2"))
                {
                    rstr = "{\"dimensions\":[\"product\",\"data1\"],\"source\":[{\"product\":\"Thu\",\"data1\":80},{\"product\":\"Fri\",\"data1\":70}]}";
                }
                return Return_Info(0, "", rstr);
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
            }
            return null;
        }

        /**
        * 蓝色大屏-动态数据测试3
        * @param key
        * @param sql
        * @return
         */
        [HttpGet, HttpPost]
        public object sql(string key, string sql)
        {
            try
            {
                // System.out.println("test3：" + key);
                //System.out.println("sql:" + sql);
                string p = "";
                string rstr = "sql默认文本";
                if (key != null && !key.Equals(""))
                {
                   // System.out.println("key:" + key);
                    p = key;
                }

                if (p.Equals("1"))
                {
                    rstr = "sql选项1";
                }
                else if (p.Equals("2"))
                {
                    rstr = "sql选项2";
                }
                return Return_Info(0, "", rstr);
            }
            catch (Exception e)
            {
                BP.DA.Log.DebugWriteError(e);
            }
            return null;
        }

        /// <summary>
        /// 获得Search的数据.
        /// </summary>
        /// <param name="token">token</param>
        /// <param name="searchID"></param>
        /// <param name="paras">参数: @key=val@key1=val1</param>
        /// <returns></returns>
        [HttpGet, HttpPost, HttpPut]
        public Object DBSrc_GenerSearchData(string token, string searchID, string paras)
        {
            try
            {
                //根据token登录.
                Dev2Interface.Port_LoginByToken(token);
                SFSearch sFSearch = new SFSearch(searchID);
                string strs = sFSearch.GenerDataOfJson(paras);
                return Return_Info(200, "执行成功", strs);
            }
            catch (Exception ex)
            {
                return Return_Info(300, "失败", ex.Message);
            }
        }
        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="token"></param>
        /// <param name="searchID"></param>
        /// <param name="paras"></param>
        /// <returns></returns>
          [HttpGet, HttpPost]
        public Object DBSrc_SearchList(string token)
        {
            try
            {
                //根据token登录.
                Dev2Interface.Port_LoginByToken(token);
                string sql = "select s.no,s.name ,s.fk_sfdbsrc,d.name dbname from sys_sfsearch s left join Sys_SFDBSrc d on s.FK_SFDBSrc=d.no order by fk_sfdbsrc";
                DataTable dt = DBAccess.RunSQLReturnTable(sql);
                return Return_Info(200, "执行成功", Json.ToJson(dt));
            }
            catch (Exception ex)
            {
                return Return_Info(300, "失败", ex.Message);
            }
        }

    }
}
